package com.lch.thread.vip.happensBefore;

/**
 * @author: liuchenhui
 * @create: 2019-05-15 21:32
 **/
public class Demo {
    int a = 0;
    volatile boolean flag = true;

    public void writer() {
        a = 1;
        flag = false;
    }

    public void reader() {
        if (flag) {
            int x = a;
        }
    }
}
